package app.msy.cn.takephoto;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import java.io.File;

import app.msy.cn.takephoto.util.FileUtil;
import app.msy.cn.takephoto.util.ImageUtil;
import butterknife.BindView;
import butterknife.ButterKnife;

public class FilterImageActivity extends AppCompatActivity {

    @BindView(R.id.img_filter)
    ImageView imgFilter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_filter_image);
        ButterKnife.bind(this);

        String path = getIntent().getStringExtra("newPath");

        ImageUtil.compressImage(this, path, new ImageUtil.OnSingleImageCompressedListener() {
            @Override
            public void onSuccess(File file) {

                Bitmap filterBitmap = ImageUtil.filterImage(file.getPath(), FilterImageActivity.this);
                String filterPath = FileUtil.saveBitmap(filterBitmap, FileUtil.getImageDir() + System.currentTimeMillis() + ".jpg");
                imgFilter.setImageBitmap(BitmapFactory.decodeFile(filterPath));
            }
        });
    }
}
